package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import controller.viewController.CustomerManagementController;

public class CustomerManagement {

	private JFrame frame;
	private JTextField textFieldCustomerID;
	private JTextField textFieldCompanyName;
	private JTextField textFieldContactPerson;
	private JTextField textFieldComments;
	private JTextField textFieldBranch;
	private JTextField textFieldEmail;
	private JTextField textFieldPhoneNumber;
	private JTextField textFieldStreet;
	private JTextField textFieldPLZ;
	private JTextField textFieldState;
	private JTextField textFieldCity;
	
	private CustomerManagementController cmc;

	/**
	 * Launch the application.
	 */
//	public static void main(String[] args) {
//		EventQueue.invokeLater(new Runnable() {
//			public void run() {
//				try {
//					CustomerManagement window = new CustomerManagement();
//					window.frame.setVisible(true);
//				} catch (Exception e) {
//					e.printStackTrace();
//				}
//			}
//		});
//	}

	/**
	 * Create the application.
	 */
	public CustomerManagement() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setResizable(false);
		frame.setBounds(100, 100, 730, 475);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JLabel lblCustomerID = new JLabel("KundenID:");
		lblCustomerID.setBounds(20, 11, 93, 14);
		frame.getContentPane().add(lblCustomerID);
		
		JLabel lblCompanyName = new JLabel("Firmenname:");
		lblCompanyName.setBounds(20, 42, 93, 14);
		frame.getContentPane().add(lblCompanyName);
		
		JLabel lblContactPerson = new JLabel("Ansprechpartner:");
		lblContactPerson.setBounds(20, 73, 93, 14);
		frame.getContentPane().add(lblContactPerson);
		
		JLabel lblComments = new JLabel("Bemerkungen:");
		lblComments.setBounds(20, 104, 93, 14);
		frame.getContentPane().add(lblComments);
		
		JLabel lblBranch = new JLabel("Branche:");
		lblBranch.setBounds(20, 135, 93, 14);
		frame.getContentPane().add(lblBranch);
		
		JLabel lblEmail = new JLabel("Email:");
		lblEmail.setBounds(20, 166, 93, 14);
		frame.getContentPane().add(lblEmail);
		
		JLabel lblPhoneNumber = new JLabel("Rufnummer:");
		lblPhoneNumber.setBounds(20, 197, 93, 14);
		frame.getContentPane().add(lblPhoneNumber);
		
		JLabel lblAdress = new JLabel("Adresse");
		lblAdress.setBounds(20, 228, 93, 14);
		frame.getContentPane().add(lblAdress);
		
		JLabel lblStreet = new JLabel("Stra\u00DFe:");
		lblStreet.setBounds(20, 259, 93, 14);
		frame.getContentPane().add(lblStreet);
		
		JLabel lblPLZ = new JLabel("Postleitzahl:");
		lblPLZ.setBounds(20, 290, 93, 14);
		frame.getContentPane().add(lblPLZ);
		
		JLabel lblState = new JLabel("Bundesland:");
		lblState.setBounds(20, 321, 93, 14);
		frame.getContentPane().add(lblState);
		
		JLabel lblCity = new JLabel("Stadt:");
		lblCity.setBounds(20, 352, 93, 14);
		frame.getContentPane().add(lblCity);
		
		textFieldCustomerID = new JTextField();
		textFieldCustomerID.setBounds(117, 8, 70, 20);
		frame.getContentPane().add(textFieldCustomerID);
		textFieldCustomerID.setColumns(10);
		
		textFieldCompanyName = new JTextField();
		textFieldCompanyName.setBounds(117, 39, 280, 20);
		frame.getContentPane().add(textFieldCompanyName);
		textFieldCompanyName.setColumns(10);
		
		textFieldContactPerson = new JTextField();
		textFieldContactPerson.setBounds(117, 70, 280, 20);
		frame.getContentPane().add(textFieldContactPerson);
		textFieldContactPerson.setColumns(10);
		
		textFieldComments = new JTextField();
		textFieldComments.setBounds(117, 101, 280, 20);
		frame.getContentPane().add(textFieldComments);
		textFieldComments.setColumns(10);
		
		textFieldBranch = new JTextField();
		textFieldBranch.setBounds(117, 132, 93, 20);
		frame.getContentPane().add(textFieldBranch);
		textFieldBranch.setColumns(10);
		
		textFieldEmail = new JTextField();
		textFieldEmail.setBounds(117, 163, 280, 20);
		frame.getContentPane().add(textFieldEmail);
		textFieldEmail.setColumns(10);
		
		textFieldPhoneNumber = new JTextField();
		textFieldPhoneNumber.setBounds(117, 194, 280, 20);
		frame.getContentPane().add(textFieldPhoneNumber);
		textFieldPhoneNumber.setColumns(10);
		
		textFieldStreet = new JTextField();
		textFieldStreet.setBounds(117, 256, 280, 20);
		frame.getContentPane().add(textFieldStreet);
		textFieldStreet.setColumns(10);
		
		textFieldPLZ = new JTextField();
		textFieldPLZ.setBounds(117, 287, 93, 20);
		frame.getContentPane().add(textFieldPLZ);
		textFieldPLZ.setColumns(10);
		
		textFieldState = new JTextField();
		textFieldState.setBounds(117, 318, 280, 20);
		frame.getContentPane().add(textFieldState);
		textFieldState.setColumns(10);
		
		textFieldCity = new JTextField();
		textFieldCity.setBounds(117, 349, 280, 20);
		frame.getContentPane().add(textFieldCity);
		textFieldCity.setColumns(10);
		
		JLabel lblBotlane = new JLabel("PlEnTra /Kunden verwalten");
		lblBotlane.setBounds(10, 420, 694, 14);
		frame.getContentPane().add(lblBotlane);
		
		JButton btnSearchCustomer = new JButton("Kunden suchen");
		btnSearchCustomer.setBounds(20, 386, 150, 23);
		frame.getContentPane().add(btnSearchCustomer);
		btnSearchCustomer.addActionListener(action_btnSearchCustomer);
		
		JButton btnAddCustomer = new JButton("Kunden hinzuf\u00FCgen");
		btnAddCustomer.setBounds(180, 386, 150, 23);
		frame.getContentPane().add(btnAddCustomer);
		btnAddCustomer.addActionListener(action_btnAddCustomer);
		
		JButton btnRefreshCustomer = new JButton("Kunden aktualisieren");
		btnRefreshCustomer.setBounds(340, 386, 150, 23);
		frame.getContentPane().add(btnRefreshCustomer);
		btnRefreshCustomer.addActionListener(action_btnRefreshCustomer);
		
		JButton btnBack = new JButton("Zur\u00FCck");
		btnBack.setBounds(500, 386, 150, 23);
		frame.getContentPane().add(btnBack);
		btnBack.addActionListener(action_btnBack);
		
		frame.setVisible(true);
		
	}

	public ActionListener action_btnSearchCustomer = new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			cmc.searchCustomer();
			
		}
	};
	
	public ActionListener action_btnAddCustomer = new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			
		}
	};
	
	public ActionListener action_btnRefreshCustomer = new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			
		}
	};

	public ActionListener action_btnBack = new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent arg0) {
			
			frame.setVisible(false);
			
		}
	};
}
